--- Demonstrate working of "MonadFail" issue
module tests.comp.Issue152 where


foo xs = [ 2*x | ("this", x) <- xs ]
bar xs = do { ("this", x) <- xs; return (2*x) }

items = [("this", 21), ("that", 1)]

main = do
    println $ foo items    --  [42]
    println $ bar items    -- used to abort due to pattern match failure
    println $ bar (Just ("this", 21))    -- Just 42
    println $ (bar (Right ("that", 21)) :: (String | Int))  -- Left "pattern match failure ..."
--  don't disturb interactive regression
--    println "Enter \"quit\" for graceful exit, anything else for abortion."
--    "quit" <- getLine
    pure ()